﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Farigola.Engine;
using Farigola.Engine.Reposit;

using Farigola.Engine.PersistXml;
using Farigola.Engine.SystemData.Entity.inst;
using Farigola.Engine.PersistXml.TestUnit;

namespace DevTestApp
{
    /// <summary>
    /// To dev and test the persistence of the project.
    /// </summary>
    public class TestPersistProject
    {
        /// <summary>
        /// Test the concrete xml persistence: Farigola.Engine.PersistXml
        /// need to reference this dll.
        /// </summary>
        public void TestSaveAndLoadProject()
        {
            bool res;

            IEngineReposit engineReposit= new EngineRepositXml();

            Engine engine = new Engine(engineReposit);
            engine.Init();
            Workspace wksp = engine.GetWorkspace();

            // create a project wit some content
            Project prj = wksp.CreateActiveProject("MyProject");

            // todo: add folder, ent string
            EntInstFolder fold= prj.createEntInstFolder("fold");
            prj.createEntInstString(fold, "s");

            prj.createEntInstString("str");

            // save the project
            res = wksp.SaveActiveProject(@"E:\_diskz\temp\MyProject.zip");

            // close (and clear) the active project
            wksp.CloseActiveProject();

            // now, load the saved project, becomes the active project
            Project prjLoad = wksp.LoadActiveProject(@"E:\_diskz\temp\MyProject.zip");

            // check the project
            // todo:
        }

        /// <summary>
        /// Test the concrete xml persistence: Farigola.Engine.PersistXml
        /// need to reference this dll.
        /// </summary>
        public void TestLoadProject()
        {
            IEngineReposit engineReposit = new EngineRepositXml();

            Engine engine = new Engine(engineReposit);
            engine.Init();
            Workspace wksp = engine.GetWorkspace();

            // now, load the saved project, becomes the active project
            Project prjLoad = wksp.LoadActiveProject(@"E:\_diskz\temp\MyProject.zip");

            // check the project
            // todo:

        }

        public void TestTheTestUnit()
        {
            EngineRepositXmlTestUnit e= new EngineRepositXmlTestUnit();
            e.SaveProjectEmptyCloseActiveProject();
        }
    }
}
